home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-M68K / SPINLOCK.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  67 lines

  1. #ifndef __M68K_SPINLOCK_H
  2. #define __M68K_SPINLOCK_H
  3.  
  4. /*
  5.  * We don't do SMP on the m68k .... at least not yet.
  6.  */
  7.  
  8. /*
  9.  * Gcc-2.7.x has a nasty bug with empty initializers.
  10.  */
  11. #if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
  12. typedef struct { } spinlock_t;
  13. #define SPIN_LOCK_UNLOCKED (spinlock_t) { }
  14. #else
  15. typedef struct { int gcc_is_buggy; } spinlock_t;
  16. #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
  17. #endif
  18.  
  19. #define spin_lock_init(lock)    do { } while(0)
  20. #define spin_lock(lock)        do { } while(0)
  21. #define spin_trylock(lock)    do { } while(0)
  22. #define spin_unlock_wait(lock)    do { } while(0)
  23. #define spin_unlock(lock)    do { } while(0)
  24. #define spin_lock_irq(lock)    cli()
  25. #define spin_unlock_irq(lock)    sti()
  26.  
  27. #define spin_lock_irqsave(lock, flags) \
  28.     do { save_flags(flags); cli(); } while (0)
  29. #define spin_unlock_irqrestore(lock, flags) \
  30.     restore_flags(flags)
  31.  
  32. /*
  33.  * Read-write spinlocks, allowing multiple readers
  34.  * but only one writer.
  35.  *
  36.  * NOTE! it is quite common to have readers in interrupts
  37.  * but no interrupt writers. For those circumstances we
  38.  * can "mix" irq-safe locks - any writer needs to get a
  39.  * irq-safe write-lock, but readers can get non-irqsafe
  40.  * read-locks.
  41.  *
  42.  * Gcc-2.7.x has a nasty bug with empty initializers.
  43.  */
  44. #if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
  45. typedef struct { } rwlock_t;
  46. #define RW_LOCK_UNLOCKED (rwlock_t) { }
  47. #else
  48. typedef struct { int gcc_is_buggy; } rwlock_t;
  49. #define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
  50. #endif
  51.  
  52. #define read_lock(lock)        do { } while(0)
  53. #define read_unlock(lock)    do { } while(0)
  54. #define write_lock(lock)    do { } while(0)
  55. #define write_unlock(lock)    do { } while(0)
  56. #define read_lock_irq(lock)    cli()
  57. #define read_unlock_irq(lock)    sti()
  58. #define write_lock_irq(lock)    cli()
  59. #define write_unlock_irq(lock)    sti()
  60.  
  61. #define read_lock_irqsave(lock, flags)        save_and_cli(flags)
  62. #define read_unlock_irqrestore(lock, flags)    restore_flags(flags)
  63. #define write_lock_irqsave(lock, flags)        save_and_cli(flags)
  64. #define write_unlock_irqrestore(lock, flags)    restore_flags(flags)
  65.  
  66. #endif
  67.